package com.shopcart.entity;

import java.util.Collection;
import java.util.HashSet;

import javax.persistence.Column;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

@Entity
@Table(name = "SHOP_CUSTOMER")
public class Customer implements java.io.Serializable {

	private static final long serialVersionUID = -839688593582520650L;

	@TableGenerator(name = "customerIdGen", table = "SHOP_SEQUENCE_GENERATOR", pkColumnName = "GEN_KEY", valueColumnName = "GEN_VALUE", pkColumnValue = "CUSTOMER_ID", initialValue = 1, allocationSize = 1)
	@Id
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "customerIdGen")
	@Column(name = "CUSTOMER_ID", nullable = false)
	private Long id;

	@Column(name = "FIRST_NAME")
	private String firstName;

	@Column(name = "LAST_NAME")
	private String lastName;

	@OneToMany
	private Collection<CartItem> itemsNotInStock = new HashSet<CartItem>();

	/** Creates a new instance of Customer */
	public Customer() {
	}

	public Customer(Long id, String firstName, String lastName,
			Collection<CartItem> itemsNotInStock) {
		this.id = id;
		this.firstName = firstName;
		this.lastName = lastName;
		this.itemsNotInStock = itemsNotInStock;
	}

	public Long getCustomerId() {
		return this.id;
	}

	public void setCustomerId(Long customerId) {
		this.id = customerId;
	}

	public String getLastName() {
		return this.lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getFirstName() {
		return this.firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public Collection<CartItem> getItemsNotInStock() {
		return itemsNotInStock;
	}

	public void setItemsNotInStock(Collection<CartItem> itemsNotInStock) {
		this.itemsNotInStock = itemsNotInStock;
	}
}